package bo;

import android.app.Activity;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class IsConnected {
	Activity parentActivity;
	public IsConnected(Activity parentActivity){this.parentActivity=parentActivity;}
	public boolean isConnectedToInternet(){
	    ConnectivityManager connectivity = (ConnectivityManager)parentActivity.getSystemService(parentActivity.CONNECTIVITY_SERVICE);
	      if (connectivity != null) 
	      {
	          NetworkInfo[] info = connectivity.getAllNetworkInfo();
	          if (info != null) 
	              for (int i = 0; i < info.length; i++) 
	                  if (info[i].getState() == NetworkInfo.State.CONNECTED)
	                  {
	                      return true;
	                  }

	      }
	      return false;
	}
}
